---
title: ChromaDB Agent Knowledge
sidebarTitle: ChromaDB
---

## Setup

```shell
pip install chromadb
```

## Example

```python agent_with_knowledge.py
import asyncio

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.chroma import ChromaDb

# Create Knowledge Instance with ChromaDB
knowledge = Knowledge(
    name="Basic SDK Knowledge Base",
    description="Agno 2.0 Knowledge Implementation with ChromaDB",
    vector_db=ChromaDb(
        collection="vectors", path="tmp/chromadb", persistent_client=True
    ),
)

asyncio.run(
    knowledge.add_content_async(
        name="Recipes",
        url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
        metadata={"doc_type": "recipe_book"},
    )
)

# Create and use the agent
agent = Agent(knowledge=knowledge)
agent.print_response("List down the ingredients to make Massaman Gai", markdown=True)

# Delete operations examples
vector_db = knowledge.vector_db
vector_db.delete_by_name("Recipes")
# or
vector_db.delete_by_metadata({"user_tag": "Recipes from website"})
```

### For hosted ChromaDB (Chroma Cloud)
```python
from chromadb.config import Settings

vector_db = ChromaDb(
    collection="vectors",
    settings=Settings(
        chroma_api_impl="chromadb.api.fastapi.FastAPI",
        chroma_server_host="your-tenant-id.api.trychroma.com",
        chroma_server_http_port=443,
        chroma_server_ssl_enabled=True,
        chroma_client_auth_provider="chromadb.auth.token_authn.TokenAuthClientProvider",
        chroma_client_auth_credentials="your-api-key"
    )
)
```

<Card title="Async Support ⚡">
  <div className="mt-2">
    <p>
      ChromaDB also supports asynchronous operations, enabling concurrency and leading to better performance.
    </p>
    
    ```python async_chroma_db.py
    # install chromadb - `pip install chromadb`

    import asyncio

    from agno.agent import Agent
    from agno.knowledge.knowledge import Knowledge
    from agno.vectordb.chroma import ChromaDb

    # Initialize ChromaDB
    vector_db = ChromaDb(collection="recipes", path="tmp/chromadb", persistent_client=True)

    # Create knowledge base
    knowledge = Knowledge(
        vector_db=vector_db,
    )

    # Create and use the agent
    agent = Agent(knowledge=knowledge)

    if __name__ == "__main__":
        # Comment out after first run
        asyncio.run(
            knowledge.add_content_async(url="https://docs.agno.com/introduction/agents.md")
        )

        # Create and use the agent
        asyncio.run(
            agent.aprint_response("What is the purpose of an Agno Agent?", markdown=True)
        )
    ```
    
    <Tip className="mt-4">
      Use <code>add_content_async()</code> and <code>aprint_response()</code> methods with <code>asyncio.run()</code> for non-blocking operations in high-throughput applications.
    </Tip>
  </div>
</Card>

## ChromaDb Params

<Snippet file="vectordb_chromadb_params.mdx" />

## Developer Resources

- View [Cookbook (Sync)](https://github.com/agno-agi/agno/blob/main/cookbook/knowledge/vector_db/chroma_db/chroma_db.py)
- View [Cookbook (Async)](https://github.com/agno-agi/agno/blob/main/cookbook/knowledge/vector_db/chroma_db/async_chroma_db.py)
